<?php
namespace app\admin\validate;
use think\Validate;
use think\Db;
class StoreGoods extends Validate
{

    // 验证规则
    protected $rule = [
        'id'              =>'checkGoodsId',
        'gname'            => 'require|min:3|max:48',
        'price'            =>['require','regex'=>'([0-9]\d*(\.\d*[0-9])?)|(0\.\d*[0-9])']
    ];
    //错误信息
    protected $message  = [
        'gname.require'                            => '名称必填',
        'gname.min'                                => '名称长度至少3个字符',
        'gname.max'                                => '名称长度至多16个汉字',
        'gname.unique'                             => '名称重复',
        'price.require'                            => '本店售价必须',
        'price.regex'                              => '本店售价格式不对'
    ];


    /**
     * 检查是否有商品规格参加活动，若有则不能编辑商品
     * @param $value
     * @return bool
     */
    protected function checkGoodsId($value){
        return true;
    }

}